<%@ tag language="java" pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<%@ attribute name="replace" type="java.lang.String" required="true" description="需要替换的textarea编号"%>
<%@ attribute name="uploadPath" type="java.lang.String" required="false" description="文件上传路径，路径后自动添加年份。若不指定，则编辑器不可上传文件"%>
<%@ attribute name="height" type="java.lang.String" required="false" description="编辑器高度"%>
<%@ attribute name="toolbar" type="java.lang.String" required="false" description="工具兰选项，simple：简单；full：全部；docmunt：文档编辑；否则：自定义"%>
<script type="text/javascript">include('ckeditor_lib','${ctxStatic}/ckeditor/',['ckeditor.js']);</script>
<script type="text/javascript">
	var toolbar = "${toolbar}";
	var ${replace}Ckeditor = CKEDITOR.replace("${replace}");
	if("simple" == toolbar){
		$.extend(${replace}Ckeditor.config,{
            toolbar: [{
                name: "document",
                items: ["Print"]
            }, {
                name: "clipboard",
                items: ["Undo", "Redo"]
            }, {
                name: "styles",
                items: ["Format", "Font", "FontSize"]
            }, {
                name: "basicstyles",
                items: ["Bold", "Italic", "Underline", "Strike", "RemoveFormat", "CopyFormatting"]
            }, {
                name: "colors",
                items: ["TextColor", "BGColor"]
            }, {
                name: "align",
                items: ["JustifyLeft", "JustifyCenter", "JustifyRight", "JustifyBlock"]
            }, {
                name: "links",
                items: ["Link", "Unlink"]
            }, {
                name: "paragraph",
                items: ["NumberedList", "BulletedList", "-", "Outdent", "Indent", "-", "Blockquote"]
            }, {
                name: "insert",
                items: ["Image", "Table"]
            }, {
                name: "tools",
                items: ["Maximize"]
            }, {
                name: "editing",
                items: ["Scayt"]
            }],
            removePlugins: "autoembed,embedsemantic,image2,sourcedialog",
            disallowedContent: "img{width,height,float}",
            extraAllowedContent: "img[width,height,align]",
            bodyClass: "document-editor"
        });
	}else if("document" == toolbar){
		$.extend(${replace}Ckeditor.config,{
            toolbar: [{
                name: "document",
                items: ["Print"]
            }, {
                name: "clipboard",
                items: ["Undo", "Redo"]
            }, {
                name: "styles",
                items: ["Format", "Font", "FontSize"]
            }, {
                name: "basicstyles",
                items: ["Bold", "Italic", "Underline", "Strike", "RemoveFormat", "CopyFormatting"]
            }, {
                name: "colors",
                items: ["TextColor", "BGColor"]
            }, {
                name: "align",
                items: ["JustifyLeft", "JustifyCenter", "JustifyRight", "JustifyBlock"]
            }, {
                name: "links",
                items: ["Link", "Unlink"]
            }, {
                name: "paragraph",
                items: ["NumberedList", "BulletedList", "-", "Outdent", "Indent", "-", "Blockquote"]
            }, {
                name: "insert",
                items: ["Image", "Table"]
            }, {
                name: "tools",
                items: ["Maximize"]
            }, {
                name: "editing",
                items: ["Scayt"]
            }],
            removePlugins: "autoembed,embedsemantic,image2,sourcedialog",
            disallowedContent: "img{width,height,float}",
            extraAllowedContent: "img[width,height,align]",
            bodyClass: "document-editor"
        });
	}else if("article" == toolbar){
		$.extend(${replace}Ckeditor.config,{
            toolbar: [{
                name: "clipboard",
                items: ["Undo", "Redo"]
            }, {
                name: "styles",
                items: ["Styles", "Format"]
            }, {
                name: "basicstyles",
                items: ["Bold", "Italic", "Strike", "-", "RemoveFormat"]
            }, {
                name: "paragraph",
                items: ["NumberedList", "BulletedList", "-", "Outdent", "Indent", "-", "Blockquote"]
            }, {
                name: "links",
                items: ["Link", "Unlink"]
            }, {
                name: "insert",
                items: ["Image", "EmbedSemantic",'flash', "Table"]
            }, {
                name: "tools",
                items: ["Maximize"]
            }, {
                name: "editing",
                items: ["Scayt"]
            }],
            removePlugins: "colorbutton,colordialog,copyformatting,font,indentblock,image,justify,liststyle,print,sourcedialog,tableresize",
            height: 461,
            bodyClass: "article-editor"
        });
	}else{
		$.extend(${replace}Ckeditor.config,{
			toolbarGroups: [
    			{ name: 'document', groups: [ 'mode', 'document', 'doctools' ] },
    			{ name: 'clipboard', groups: [ 'clipboard', 'undo' ] },
    			{ name: 'editing', groups: [ 'find', 'selection', 'spellchecker', 'editing' ] },
    			{ name: 'forms', groups: [ 'forms' ] },
    			'/',
    			{ name: 'basicstyles', groups: [ 'basicstyles', 'cleanup' ] },
    			{ name: 'paragraph', groups: [ 'list', 'indent', 'blocks', 'align', 'bidi', 'paragraph' ] },
    			{ name: 'links', groups: [ 'links' ] },
    			{ name: 'insert', groups: [ 'insert' ] },
    			'/',
    			{ name: 'styles', groups: [ 'styles' ] },
    			{ name: 'colors', groups: [ 'colors' ] },
    			{ name: 'tools', groups: [ 'tools' ] },
    			{ name: 'others', groups: [ 'others' ] }
    		],
            extraAllowedContent: "img[width,height,align]"
        });
	}
	${replace}Ckeditor.config.height = "${height}";//<c:if test="${not empty uploadPath}">
	${replace}Ckeditor.config.skin='kama';  
	${replace}Ckeditor.config.ckfinderPath="${ctxStatic}/ckfinder";
	var date = new Date(), year = date.getFullYear(), month = (date.getMonth()+1)>9?date.getMonth()+1:"0"+(date.getMonth()+1);
	${replace}Ckeditor.config.ckfinderUploadPath="${uploadPath}/"+year+"/"+month+"/";//</c:if>
</script>